<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/css/bootstrap-switch.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-parameter-edit" th:object="${parameter}">
            <input id="apiParameterId" name="apiParameterId" th:field="*{apiParameterId}"  type="hidden">
            <input id="required" name="required" type="hidden" th:value="*{required}" >
            <div class="form-group">
                <label class="col-sm-3 control-label">所属项目：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" id="treeName" readonly="true" th:value="${project.description}"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">参数名称：</label>
                <div class="col-sm-8">
                    <input id="parameter" name="parameter" th:field="*{parameter}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">参数描述：</label>
                <div class="col-sm-8">
                    <input id="description" name="description" th:field="*{description}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">传参方式：</label>
                <div class="col-sm-8">
                    <!--<input id="transmissionMode" name="transmissionMode" class="form-control" type="text">-->
                    <select id="transmissionMode" name="transmissionMode" class="form-control m-b" th:with="type=${@dict.getType('param_transmission_mode')}" th:field="*{transmissionMode}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">默认值：</label>
                <div class="col-sm-8">
                    <input id="defaultValue" name="defaultValue" th:field="*{defaultValue}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">参考值：</label>
                <div class="col-sm-8">
                    <input id="referenceValue" name="referenceValue" th:field="*{referenceValue}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">值类型：</label>
                <div class="col-sm-8">
                    <!--<input id="method"  name="method" class="form-control" type="text">-->
                    <select id="valueType" name="valueType" class="form-control m-b" th:with="type=${@dict.getType('api_value_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:field="*{valueType}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">是否必填：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="checked_required" name="checked_required"/>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">创建者：</label>
                <div class="col-sm-8">
                    <input id="createBy" name="createBy" th:field="*{createBy}" class="form-control" type="text" readonly="true">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8">
                    <input id="createTime" name="createTime" th:field="*{createTime}" class="form-control" type="text" readonly="true">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">更新者：</label>
                <div class="col-sm-8">
                    <input id="updateBy" name="updateBy" th:field="*{updateBy}" class="form-control" type="text" readonly="true">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">更新时间：</label>
                <div class="col-sm-8">
                    <input id="updateTime" name="updateTime" th:field="*{updateTime}" class="form-control" type="text" readonly="true">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script th:src="@{/js/bootstrap-switch.js}"></script>
    <script type="text/javascript" >
		var prefix = ctx + "module/parameter"
		$("#form-parameter-edit").validate({
			rules:{
                parameter:{
                    required:true,
                },
                description:{
                    required:true,
                },
			},
			submitHandler: function(form) {
				$.operate.save(prefix + "/edit", $('#form-parameter-edit').serialize());
			}
		});

        $("#checked_required").bootstrapSwitch({
            onText:"√",
            offText:"×",
            onColor:"success",
            offColor:"default",
            size:"small",
            onSwitchChange: function(event,state) {
                console.log("state="+state);
                console.log(event);
                event
                if (state == true) {
                    $("#required").val('1');
                } else {
                    $("#required").val('0');
                }
            }
        });
    </script>
    <script th:inline="javascript">
        /*<![CDATA[*/
        var checked_state = [[${parameter.required}]];
        /*]]>*/
        if(checked_state=='1'){

            $('#checked_required').bootstrapSwitch('state', true);
        }else{
            $('#checked_required').bootstrapSwitch('state', false);
        }
        console.log("checked_state="+checked_state);
    </script>
</body>
</html>
